package com.hzx.controller;

import com.hzx.Activity;
import com.hzx.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/activity")
public class ActivityController {
    @Autowired
    ActivityService activityService;

    @GetMapping(value = "/detail")
    public Activity activityDetailSearch(@RequestParam("aId") int aId) {
        return activityService.activityDetailSearch(aId);
    }

    @GetMapping("/all")
    public Activity[] activitySearch() {
        return activityService.activitySearch().toArray(new Activity[0]);
    }

    @GetMapping("/add")
    public boolean addActivity(@RequestParam("title") String title, @RequestParam("text") String text, @RequestParam("year") int year, @RequestParam("month") int month, @RequestParam("day") int day, @RequestParam("hour") int hour, @RequestParam("num") int num) {
        return activityService.addActivity(title, text, year, month, day, hour, num);
    }
}
